<?php
include_once '../meihe/common.php';
if($islogin==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");  
$title='订单支付记录';
include_once './head.php';
?>

<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header">
                订单支付记录&nbsp;&nbsp;&nbsp;<a href="javascript:searchClear()" class="badge badge-danger-info" title="刷新支付记录"><i class="layui-icon layui-icon-refresh"></i> 刷新</a>
            </div>
            <div class="card-body">
                <div class="layui-elem-quote" id="blocktitle"></div>
                <form onsubmit="return searchOrder()" method="GET" class="form layui-form">
                    <div class="form-group mb-3">
                        <select class="form-control" name="type"><option value="0">全部</option><option value="1">订单号</option><option value="2">购买类型</option><option value="3">订单数据</option></select>
                    </div>
                    <div class="form-group mb-3" id="searchword">
                        <input type="text" class="form-control" name="kw" placeholder="搜索内容" value="">
                    </div>
                    <div class="form-group mb-3">
                        <select class="form-control" name="method" lay-search><option value="0">精确搜索</option><option value="1">模糊搜索</option></select>
                    </div>
                    <div class="form-group mb-3">
                        <button class="btn btn-outline-primary" type="submit"><i class="layui-icon layui-icon-search"></i> 搜索</button>
                    </div>
                </form>
            <div id="listTable"></div>
        </div>
    </div>
</div>
<?php
include_once './bottom.php';
?>
<script type="text/javascript">
function listTable(query){
	var url = window.document.location.href.toString();
	var queryString = url.split("?")[1];
	query = query || queryString;
	if(query == 'start' || query == undefined){
		query = '';
		history.replaceState({}, null, './paylogs.php');
	}else if(query != undefined){
		history.replaceState({}, null, './paylogs.php?'+query);
	}
	layer.closeAll();
	var ii = layer.msg('正在获取日志中,请稍后...', {icon: 16, time: 10 * 1000});
	$.ajax({
		type : 'GET',
		url : 'paylogs-table.php?'+query,
		dataType : 'html',
		cache : false,
		success : function(data) {
			layer.close(ii);
			$("#listTable").html(data)
		},
		error:function(data){
			layer.msg('服务器错误', {icon: 5});
			return false;
		}
	});
}
function searchOrder(){
	var type=$("select[name='type']").val();
	var kw=$("input[name='kw']").val();
	var method=$("select[name='method']").val();
	if(kw==''){
		listTable('start');
	}else{
		listTable('type='+type+'&kw='+kw+'&method='+method);
	}
	return false;
}
function searchClear(){
	$("select[name='type']").val(0);
	$("input[name='kw']").val('');
	$("select[name='method']").val(0);
	listTable('start');
}
$(document).ready(function(){
	var items = $("select[default]");
	for (i = 0; i < items.length; i++) {
		$(items[i]).val($(items[i]).attr("default")||0);
	}
	listTable();
})
</script>